package org.jradweb.tools.generator.freemarker.util;

import java.io.IOException;

import freemarker.template.Configuration;
import freemarker.template.Template;
/**
 * Inilalized templates
 *
 * Created On 2008-2-29
 * @author <a href="mailto:wagzhi@gmail.com">Paul Wang</a>
 * @version $Id: Templates.java 100 2008-04-15 10:37:55Z wagzhi $
 */
public class Templates {
	public static Template MODEL_TEMPLATE;
	public static Template CONTROLLER_TEMPLATE;	
	public static Template DAO_TEMPLATE;
	public static Template DAO_IMPL_TEMPLATE;
	public static Template SERVICE_TEMPLATE;
	public static Template SERVICE_ABSTRACT_TEMPLATE;
	public static Template SERVICE_IMPL_TEMPLATE;
	
	
	public static Template DAO_TEST_TEMPLATE;
	public static Template DAO_TEST_DATASET_TEMPLATE;
	public static Template MANAGER_TEMPALTE;
	public static Template MANAGER_ABSTRACT_TEMPLATE;
	public static Template MANAGER_IMPL_TEMPALTE;
	public static Template MANAGER_TEST_TEMPLATE;
	public static Template MANAGER_DATASET_TEMPLATE;
	public static Template ACTION_TEMPLATE;
	
	public static Template JSP_INDEX_TEMPLATE;
	public static Template JSP_CREATE_TEMPLATE;
	public static Template JSP_EDIT_TEMPLATE;
	public static Template JSP_SHOW_TEMPLATE;
	
	public static Template DATASET_TEMPLATE;
	static{
		try {
			Configuration conf=new Configuration();
			//conf.setLocale(java.util.Locale.CHINESE);
			conf.setLocalizedLookup(false);
			conf.setTemplateLoader(new DefaultTemplateLoader());
			MODEL_TEMPLATE=conf.getTemplate("model_class.ftl");
			CONTROLLER_TEMPLATE=conf.getTemplate("controller_class.ftl");
			DAO_TEMPLATE=conf.getTemplate("dao_class.ftl");
			DAO_IMPL_TEMPLATE=conf.getTemplate("dao_impl_class.ftl");
			SERVICE_TEMPLATE=conf.getTemplate("service_class.ftl");
			SERVICE_ABSTRACT_TEMPLATE=conf.getTemplate("service_abstract_class.ftl");
			SERVICE_IMPL_TEMPLATE=conf.getTemplate("service_impl_class.ftl");
			
			
			DAO_TEST_TEMPLATE=conf.getTemplate("dao_test_class.ftl");
			DAO_TEST_DATASET_TEMPLATE=conf.getTemplate("dao_test_dataset.ftl");
			
			MANAGER_TEMPALTE=conf.getTemplate("manager_class.ftl");
			MANAGER_ABSTRACT_TEMPLATE=conf.getTemplate("manager_abstract_class.ftl");
			MANAGER_IMPL_TEMPALTE=conf.getTemplate("manager_impl_class.ftl");
			MANAGER_TEST_TEMPLATE=conf.getTemplate("manager_test_class.ftl");
			MANAGER_DATASET_TEMPLATE=conf.getTemplate("manager_test_dataset.ftl");
			
			ACTION_TEMPLATE=conf.getTemplate("action_class.ftl");
			
			
			JSP_INDEX_TEMPLATE=conf.getTemplate("jsp_index.ftl");
			JSP_CREATE_TEMPLATE=conf.getTemplate("jsp_create.ftl");
			JSP_EDIT_TEMPLATE=conf.getTemplate("jsp_edit.ftl");
			JSP_SHOW_TEMPLATE=conf.getTemplate("jsp_show.ftl");
			DATASET_TEMPLATE=conf.getTemplate("dataset.ftl");
		} catch (IOException e) {
			throw new  RuntimeException("load freemarker template faild.",e);
		}
	}
}
